﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using pdtransport_v2._0.Models;

namespace pdtransport_v2._0.Areas.back.Controllers
{
    
    public class QuyDinhHuyDatXeController : Controller
    {
        //
        // GET: /back/QuyDinhHuyDatXe/

        pdtransportDataContext datacontext = new pdtransportDataContext();

        public ActionResult DanhSach()
        {
            List<QuyDinhHuyDatXe> qd = (from _qd in datacontext.QuyDinhHuyDatXes
                                        select _qd).ToList();

            return View(qd);
        }

        [HttpGet]
        public ActionResult Sua(int idqd)
        {
            QuyDinhHuyDatXe qd = (from _qd in datacontext.QuyDinhHuyDatXes
                                  where _qd.IDHDX == idqd
                                  select _qd).Single();
            return View(qd);
        }

        [HttpPost]
        public ActionResult Sua(int idqd, int phiphaitra)
        {
            QuyDinhHuyDatXe qd = (from _qd in datacontext.QuyDinhHuyDatXes
                                  where _qd.IDHDX == idqd
                                  select _qd).Single();
            qd.PhiPhaiTra = phiphaitra;
            datacontext.SubmitChanges();

            ViewBag.Sua = 1;

            return View(qd);
        }
    }
}
